home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 2.iso / bin / DT_xconfirm < prev    next >
Text File  |  1996-11-11  |  2KB  |  77 lines

  1. #!/bin/ksh -p
  2. # run wrapper around xconfirm so can have more flexible text for window and
  3. # so check made for failure
  4.  
  5. export PATH="/usr/bsd:/bin:/usr/bin:/usr/sbin:/usr/bin/X11"
  6.  
  7. OLD_IFS="$IFS"
  8. IFS="\n"
  9. typeset options="$1" mesg="$2" special_header="$3"
  10. IFS="$OLD_IFS"
  11. typeset -i ignore_ret=0
  12. base_button="Continue"
  13. base_error="-B $base_button -icon error"
  14. base_warn="-B $base_button -icon warning"
  15. base_info="-B $base_button -icon info"
  16. error_opt="$base_error -header \"ToolBox Error\""
  17. warn_opt="$base_warn -header \"ToolBox Warning\""
  18. info_opt="$base_info -header \"ToolBox Information\""
  19.  
  20. if [[ "$options" = "error" ]]; then
  21.     options="$error_opt"
  22.     ((ignore_ret=1))
  23. elif [[ "$options" = "warn" ]]; then
  24.     options="$warn_opt"
  25.     ((ignore_ret=1))
  26. elif [[ "$options" = "header" ]]; then
  27.     options="$base_error -header \"$special_header\""
  28.     ((ignore_ret=1))
  29. elif [[ "$options" = "notviewDT" ]]; then
  30.     options="$error_opt"
  31.     mesg="This command cannot be run in standalone mode\n\
  32.         It is run as part of viewDT from a Developer Toolbox CD\n\n\
  33.         Please read the liner notes from the CD for more details."
  34.     ((ignore_ret=1))
  35. elif [[ "$options" = "nohome" ]]; then
  36.     options="$error_opt"
  37.     mesg="Could not determine user home directory.\n\
  38.         Please make sure the environment variable HOME\n\
  39.         is set to be your user home directory.\n\
  40.         Then rerun this command."
  41.     ((ignore_ret=1))
  42. elif [[ "$options" = "yesno" ]]; then
  43.     options="-B Yes -b No -header ToolBox_Question -icon question"
  44. elif [[ "$options" = "select" ]]; then
  45.     options="-b Help -b Quit -B View -header \"Toolbox as $USER\" -icon question"
  46. elif [[ "$options" = "select_again" ]]; then
  47.     options="-b Help -B Quit -b View -header \"Toolbox as $USER\" -icon question"
  48. fi
  49.  
  50. unset tval
  51. IFS="\n"
  52. echo "$mesg" | while read line; do
  53.     tval="$tval -t \""
  54.     while [[ "${line##*\"*}" = "" ]]; do
  55.         [[ "$line" = "" ]] && break
  56.         tval="$tval${line%%\"*}\\\""
  57.         line="${line##*([!\"])\"}"
  58.     done
  59.     tval="$tval$line\""
  60. done
  61. tval="xconfirm $options $tval"
  62. IFS="$OLD_IFS"
  63. if ((ignore_ret)); then
  64.     eval $tval > /dev/null
  65. else
  66.     eval $tval
  67. fi
  68. if (($?)); then
  69.     echo "\n**********************************************************"
  70.     echo "Error when trying to run xconfirm"
  71.     echo "For some reason X programs will not successfully run."
  72.     echo "Perhaps your DISPLAY environment variable is improperly set."
  73.     echo "\nThe body of the xconfirm message was:\n\n$mesg"
  74.     echo "**********************************************************\n\n"
  75.     exit 1
  76. fi
  77.